import 'package:flutter/material.dart';
import 'package:get/get.dart';

class PasswordController extends GetxController {
  //controller
  TextEditingController passwordController = TextEditingController();
  TextEditingController repeatController = TextEditingController();
  //state
  RxBool buttonEnable = false.obs;
  //data
  RxString password = ''.obs;
  RxString repeatPassword = ''.obs;

  @override
  void onInit() {
    super.onInit();

    vaildInfo();
  }

  @override
  void onReady() {
    super.onReady();

    password.subject.listen((element) => vaildInfo());
    repeatPassword.subject.listen((element) => vaildInfo());
  }

  void vaildInfo() {
    if (password.value.length < 8) {
      buttonEnable.value = false;
      return;
    }

    if (repeatPassword.value.length < 8) {
      buttonEnable.value = false;
      return;
    }

    buttonEnable.value = true;
  }

  @override
  void onClose() {}
}
